/**
 * 
 */
package np.com.baralsujan.login.service.impl;

import java.util.HashMap;
import java.util.Map;

import np.com.baralsujan.login.da.IUserDao;
import np.com.baralsujan.login.domain.User;
import np.com.baralsujan.login.util.AuthenticationException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author sujan
 *
 */
@Service("UserService")
public class UserService implements IUserService {
	
	@Autowired
	private IUserDao userDao;
	
	@Override
	public void saveUser(User user) {
		userDao.saveUser(user);
	}
	
	@Override
	public User retrieveUser(User user) {
		return userDao.retrieveUserByUsername(user.getUserName());
	}
	
	@Override
	public boolean deleteUser(User user) {
		return userDao.deleteUser(user);
	}
	
	@Override
	public User authenticateUser(User user) throws AuthenticationException {
		Map<String, Object> criteria = new HashMap<String, Object>();
		criteria.put("userName", "baralsujan");
		criteria.put("password", "password");
		criteria.put("active", true);
		return userDao.authenticateUser(criteria);
	}
	
}
